//
//  oldHistoryOrderTableViewCell.m
//  laonianbangSupport
//
//  Created by 勇拓 李 on 18/3/1.
//  Copyright © 2018年 zaiyou. All rights reserved.
//

#import "oldHistoryOrderTableViewCell.h"

@interface oldHistoryOrderTableViewCell()
@property (weak, nonatomic) IBOutlet UIButton *star1;
@property (weak, nonatomic) IBOutlet UIButton *star2;
@property (weak, nonatomic) IBOutlet UIButton *star3;
@property (weak, nonatomic) IBOutlet UIButton *star4;
@property (weak, nonatomic) IBOutlet UIButton *star5;
@property (weak, nonatomic) IBOutlet UILabel *label_description;
@property (weak, nonatomic) IBOutlet UILabel *label_name;
@property (weak, nonatomic) IBOutlet UILabel *label_time;

@end

@implementation oldHistoryOrderTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)configWithData:(id)data
{
    if (data[@"rate"]) {
        [self starsNumber:[data[@"rate"] integerValue]];
    }
    
    if ([data[@"anonymous"] boolValue]) {
        _label_time.hidden = YES;
        _label_name.text = @"匿名";
    }
    else
    {
        _label_time.hidden = NO;
        _label_time.text = data[@"created_at"];
        _label_name.text = data[@"submitUname"];
    }
    
    _label_description.text = data[@"content"];
}

- (void)starsNumber:(NSInteger)rate
{
    switch (rate) {
        case 0:
            [_star1 setImage:[UIImage imageNamed:@"订单评价星星-空"] forState:UIControlStateNormal];
            [_star2 setImage:[UIImage imageNamed:@"订单评价星星-空"] forState:UIControlStateNormal];
            [_star3 setImage:[UIImage imageNamed:@"订单评价星星-空"] forState:UIControlStateNormal];
            [_star4 setImage:[UIImage imageNamed:@"订单评价星星-空"] forState:UIControlStateNormal];
            [_star5 setImage:[UIImage imageNamed:@"订单评价星星-空"] forState:UIControlStateNormal];
            break;
        case 1:
            [_star1 setImage:[UIImage imageNamed:@"订单评价星星-满"] forState:UIControlStateNormal];
            [_star2 setImage:[UIImage imageNamed:@"订单评价星星-空"] forState:UIControlStateNormal];
            [_star3 setImage:[UIImage imageNamed:@"订单评价星星-空"] forState:UIControlStateNormal];
            [_star4 setImage:[UIImage imageNamed:@"订单评价星星-空"] forState:UIControlStateNormal];
            [_star5 setImage:[UIImage imageNamed:@"订单评价星星-空"] forState:UIControlStateNormal];
            break;
        case 2:
            [_star1 setImage:[UIImage imageNamed:@"订单评价星星-满"] forState:UIControlStateNormal];
            [_star2 setImage:[UIImage imageNamed:@"订单评价星星-满"] forState:UIControlStateNormal];
            [_star3 setImage:[UIImage imageNamed:@"订单评价星星-空"] forState:UIControlStateNormal];
            [_star4 setImage:[UIImage imageNamed:@"订单评价星星-空"] forState:UIControlStateNormal];
            [_star5 setImage:[UIImage imageNamed:@"订单评价星星-空"] forState:UIControlStateNormal];
            break;
        case 3:
            [_star1 setImage:[UIImage imageNamed:@"订单评价星星-满"] forState:UIControlStateNormal];
            [_star2 setImage:[UIImage imageNamed:@"订单评价星星-满"] forState:UIControlStateNormal];
            [_star3 setImage:[UIImage imageNamed:@"订单评价星星-满"] forState:UIControlStateNormal];
            [_star4 setImage:[UIImage imageNamed:@"订单评价星星-空"] forState:UIControlStateNormal];
            [_star5 setImage:[UIImage imageNamed:@"订单评价星星-空"] forState:UIControlStateNormal];
            break;
        case 4:
            [_star1 setImage:[UIImage imageNamed:@"订单评价星星-满"] forState:UIControlStateNormal];
            [_star2 setImage:[UIImage imageNamed:@"订单评价星星-满"] forState:UIControlStateNormal];
            [_star3 setImage:[UIImage imageNamed:@"订单评价星星-满"] forState:UIControlStateNormal];
            [_star4 setImage:[UIImage imageNamed:@"订单评价星星-满"] forState:UIControlStateNormal];
            [_star5 setImage:[UIImage imageNamed:@"订单评价星星-空"] forState:UIControlStateNormal];
            break;
        default:
            [_star1 setImage:[UIImage imageNamed:@"订单评价星星-满"] forState:UIControlStateNormal];
            [_star2 setImage:[UIImage imageNamed:@"订单评价星星-满"] forState:UIControlStateNormal];
            [_star3 setImage:[UIImage imageNamed:@"订单评价星星-满"] forState:UIControlStateNormal];
            [_star4 setImage:[UIImage imageNamed:@"订单评价星星-满"] forState:UIControlStateNormal];
            [_star5 setImage:[UIImage imageNamed:@"订单评价星星-满"] forState:UIControlStateNormal];
            break;
    }
}

@end
